<?php
class Logger {
    private $conn;
    
    public function __construct($db_connection) {
        $this->conn = $db_connection;
    }
    
    public function log($user_id, $operation, $details = '') {
        $user_id = (int)$user_id;
        $operation = $this->conn->real_escape_string($operation);
        $details = $this->conn->real_escape_string($details);
        $ip_address = $_SERVER['REMOTE_ADDR'];
        
        $sql = "INSERT INTO operation_logs (user_id, operation, details, ip_address) 
                VALUES ($user_id, '$operation', '$details', '$ip_address')";
        
        return $this->conn->query($sql);
    }
} 